/*
 * Principal.java
 *
 * Created on 17 de Janeiro de 2008, 23:44
 */

package sisvenda;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
 *
 * @author  Cl�udio
 */
public class Principal extends javax.swing.JFrame {
    
    /** Creates new form Principal */
    public Principal() {
        initComponents();
    }
    
    Clientes clientes;
    Produtos produtos;
    Fornecedores fornecedores;
    RegistrarVenda registraVenda;
    ConsultarVendas consultaVenda;
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" C�digo Gerado ">//GEN-BEGIN:initComponents
    private void initComponents() {
        btClientes = new javax.swing.JButton();
        btProdutos = new javax.swing.JButton();
        btFornecedores = new javax.swing.JButton();
        btRegistrarVenda = new javax.swing.JButton();
        btConsultarVenda = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        mnuOpcoes = new javax.swing.JMenu();
        mnuSobre = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JSeparator();
        mnuSair = new javax.swing.JMenuItem();
        mnuCadastros = new javax.swing.JMenu();
        mnuClientes = new javax.swing.JMenuItem();
        mnuProdutos = new javax.swing.JMenuItem();
        mnuFornecedores = new javax.swing.JMenuItem();
        mnuVendas = new javax.swing.JMenu();
        mnuRegistrarVenda = new javax.swing.JMenuItem();
        mnuConsultarVenda = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Sistema de Vendas");
        btClientes.setIcon(new javax.swing.ImageIcon("./imagens/clientes.gif"));
        btClientes.setText("Clientes");
        btClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btClientesActionPerformed(evt);
            }
        });

        btProdutos.setIcon(new javax.swing.ImageIcon(".\\imagens\\produtos.gif"));
        btProdutos.setText("Produtos");
        btProdutos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btProdutosActionPerformed(evt);
            }
        });

        btFornecedores.setIcon(new javax.swing.ImageIcon(".\\imagens\\fornecedores.gif"));
        btFornecedores.setText("Fornecedores");
        btFornecedores.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btFornecedoresActionPerformed(evt);
            }
        });

        btRegistrarVenda.setIcon(new javax.swing.ImageIcon(".\\imagens\\vendas.gif"));
        btRegistrarVenda.setText("Registrar Venda");
        btRegistrarVenda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btRegistrarVendaActionPerformed(evt);
            }
        });

        btConsultarVenda.setIcon(new javax.swing.ImageIcon(".\\imagens\\vendas.gif"));
        btConsultarVenda.setText("Consultar Vendas");
        btConsultarVenda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btConsultarVendaActionPerformed(evt);
            }
        });

        mnuOpcoes.setText("Op\u00e7\u00f5es");
        mnuSobre.setText("Sobre o Sistema...");
        mnuSobre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnuSobreActionPerformed(evt);
            }
        });

        mnuOpcoes.add(mnuSobre);

        mnuOpcoes.add(jSeparator1);

        mnuSair.setText("Sair");
        mnuSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnuSairActionPerformed(evt);
            }
        });

        mnuOpcoes.add(mnuSair);

        jMenuBar1.add(mnuOpcoes);

        mnuCadastros.setText("Cadastros");
        mnuClientes.setText("Clientes");
        mnuClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnuClientesActionPerformed(evt);
            }
        });

        mnuCadastros.add(mnuClientes);

        mnuProdutos.setText("Produtos");
        mnuProdutos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnuProdutosActionPerformed(evt);
            }
        });

        mnuCadastros.add(mnuProdutos);

        mnuFornecedores.setText("Fornecedores");
        mnuFornecedores.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnuFornecedoresActionPerformed(evt);
            }
        });

        mnuCadastros.add(mnuFornecedores);

        jMenuBar1.add(mnuCadastros);

        mnuVendas.setText("Vendas");
        mnuRegistrarVenda.setText("Registrar");
        mnuRegistrarVenda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnuRegistrarVendaActionPerformed(evt);
            }
        });

        mnuVendas.add(mnuRegistrarVenda);

        mnuConsultarVenda.setText("Consultar");
        mnuConsultarVenda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnuConsultarVendaActionPerformed(evt);
            }
        });

        mnuVendas.add(mnuConsultarVenda);

        jMenuBar1.add(mnuVendas);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(btClientes, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(btProdutos))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(btFornecedores)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btRegistrarVenda)))
                    .addComponent(btConsultarVenda))
                .addContainerGap(42, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btClientes, btConsultarVenda, btFornecedores, btProdutos, btRegistrarVenda});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btProdutos)
                    .addComponent(btClientes, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btFornecedores)
                    .addComponent(btRegistrarVenda))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btConsultarVenda)
                .addContainerGap(92, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {btClientes, btConsultarVenda, btFornecedores, btProdutos, btRegistrarVenda});

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void mnuConsultarVendaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuConsultarVendaActionPerformed
        mostraConsultaVenda();
    }//GEN-LAST:event_mnuConsultarVendaActionPerformed
    private void mostraConsultaVenda(){
        if (consultaVenda == null){
            consultaVenda = new ConsultarVendas();
            consultaVenda.setVisible(true);
        } else{
            consultaVenda.setVisible(true);
            consultaVenda.setState(JFrame.NORMAL);
        }
    }
    
    private void btConsultarVendaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btConsultarVendaActionPerformed
        mostraConsultaVenda();
    }//GEN-LAST:event_btConsultarVendaActionPerformed
    
    private void mnuRegistrarVendaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuRegistrarVendaActionPerformed
        mostraRegistroVenda();
    }//GEN-LAST:event_mnuRegistrarVendaActionPerformed
    private void mostraRegistroVenda(){
        if (registraVenda == null){
            registraVenda = new RegistrarVenda();
            registraVenda.setVisible(true);
        } else{
            registraVenda.setVisible(true);
            registraVenda.setState(JFrame.NORMAL);
        }
    }
    
    private void btRegistrarVendaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btRegistrarVendaActionPerformed
        mostraRegistroVenda();
    }//GEN-LAST:event_btRegistrarVendaActionPerformed
    
    private void mnuFornecedoresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuFornecedoresActionPerformed
        mostraFornecedores();
    }//GEN-LAST:event_mnuFornecedoresActionPerformed
    
    private void mostraFornecedores(){
        if (fornecedores == null){
            fornecedores = new Fornecedores();
            fornecedores.setVisible(true);
        } else{
            fornecedores.setVisible(true);
            fornecedores.setState(JFrame.NORMAL);
        }
    }
    
    private void btFornecedoresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btFornecedoresActionPerformed
        mostraFornecedores();
    }//GEN-LAST:event_btFornecedoresActionPerformed
    
    private void btProdutosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btProdutosActionPerformed
        mostraProdutos();
    }//GEN-LAST:event_btProdutosActionPerformed
    
    private void mostraProdutos(){
        if (produtos == null){
            produtos = new Produtos();
            produtos.setVisible(true);
        } else{
            produtos.setVisible(true);
            produtos.setState(JFrame.NORMAL);
        }
        
    }
    
    private void mnuProdutosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuProdutosActionPerformed
        mostraProdutos();
    }//GEN-LAST:event_mnuProdutosActionPerformed
    
    private void btClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btClientesActionPerformed
        mostrarClientes();
    }//GEN-LAST:event_btClientesActionPerformed
    
    private void mostrarClientes(){
        if (clientes == null){
            clientes = new Clientes();
            clientes.setVisible(true);
        } else{
            clientes.setVisible(true);
            clientes.setState(JFrame.NORMAL);
        }
    }
    
    private void mnuClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuClientesActionPerformed
        mostrarClientes();
    }//GEN-LAST:event_mnuClientesActionPerformed
    
    private void mnuSobreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuSobreActionPerformed
        JOptionPane.showMessageDialog(null, "Sistema de Vendas ");
    }//GEN-LAST:event_mnuSobreActionPerformed
    
    private void sair(){
        System.exit(0);
    }
    
    private void mnuSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuSairActionPerformed
        sair();
    }//GEN-LAST:event_mnuSairActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Principal().setVisible(true);
            }
        });
    }
    
    // Declara��o de vari�veis - n�o modifique//GEN-BEGIN:variables
    private javax.swing.JButton btClientes;
    private javax.swing.JButton btConsultarVenda;
    private javax.swing.JButton btFornecedores;
    private javax.swing.JButton btProdutos;
    private javax.swing.JButton btRegistrarVenda;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JMenu mnuCadastros;
    private javax.swing.JMenuItem mnuClientes;
    private javax.swing.JMenuItem mnuConsultarVenda;
    private javax.swing.JMenuItem mnuFornecedores;
    private javax.swing.JMenu mnuOpcoes;
    private javax.swing.JMenuItem mnuProdutos;
    private javax.swing.JMenuItem mnuRegistrarVenda;
    private javax.swing.JMenuItem mnuSair;
    private javax.swing.JMenuItem mnuSobre;
    private javax.swing.JMenu mnuVendas;
    // Fim da declara��o de vari�veis//GEN-END:variables
    
}
